package com.jt.sp02.service;

import com.jt.sp01.pojo.Item;
import com.jt.sp01.service.ItemService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
@Slf4j
public class ItemServiceImpl implements ItemService {
    @Value("${server.port}")
    Integer port;

    @Override
    public List<Item> getItems(String orderId) {
        log.info("获取商品列表 orderId=" + orderId);

        List<Item> list = new ArrayList<>();
        list.add(new Item(1, "商品1", port));
        list.add(new Item(2, "商品2", 5));
        list.add(new Item(3, "商品3", 5));
        list.add(new Item(4, "商品4", 5));

        return list;
    }

    @Override
    public void decreaseNumbers(List<Item> list) {
        for (Item item : list) {
            log.info("减少库存=" + item);
        }


    }
}
